<template>
  <q-tree
    ref="qTree"
    :nodes="treeList"
    node-key="value"
    label-key="label"
    selected-color="primary"
    :selected.sync="ticked"
    @update:selected="select"
    default-expand-all
    :tick-strategy="multiple?'leaf':'none'"
    :ticked.sync="ticked"
    @update:ticked="tickedTree"
  />
</template>

<script>
export default {
  name: 'TreeItem',
  props: {
    treeList: Array,
    selected: Array,
    selNode: String,
    multiple: Boolean,
  },
  data() {
    return {
      ticked: [],
    };
  },
  created() {

  },
  mounted() {
    this.ticked = [...this.selected];
  },
  methods: {
    select(n) {
      if (n) {
        this.$emit('select', n);
      }
    },
    tickedTree() {
      this.$emit('selectMultiple', this.ticked);
    },
  },
};
</script>

<style scoped lang="stylus"></style>
